<template>
  <el-drawer size="80%" class="ex-drawer" :title="title" :visible.sync="visible" :before-close="handleClose">
    <div class="main">
      <div class="head">
        <el-form :model="queryParams" ref="queryForm" :inline="true">
          <el-form-item label="直播状态：" prop="">
            <el-select v-model="queryParams.liveStatus" placeholder="请选择" filterable>
              <el-option v-for="item in liveStatusLs" :key="item.id" :label="item.value" :value="item.id">
              </el-option>
            </el-select>
          </el-form-item>
          <el-form-item label="直播客户：" prop="">
            <el-input style="width: 250px;" v-model="queryParams.customerName" placeholder="请填写" clearable />
          </el-form-item>
          <el-form-item>
            <el-button type="primary" icon="el-icon-search" @click="handleQuery">查询</el-button>
            <el-button icon="el-icon-refresh" @click="resetQuery">重置</el-button>
          </el-form-item>
        </el-form>
      </div>
      <div class="listBox">
        <div class="listBox_head">
          <div class="listBox_head_top">
            <span>姓名：{{userInfo.name}}</span>
            <span>直播日期：{{userInfo.date}}</span>
          </div>
          <!-- <el-button type="primary" style="margin: 10px 0 20px" @click="calendarViewHandle">以日历形式查看</el-button> -->
        </div>
        <div class="listBox_line"></div>
        <div class="listBox_table">
          <el-table v-loading="loading" ref="multipleTable" :data="tabList" stripe border tooltip-effect="dark"
          style="width: 100%" >
          <el-table-column label="序号" align="center" type="index" width="64px" />
          <el-table-column label="直播日期" align="center" prop="liveDate" show-overflow-tooltip></el-table-column>
          <el-table-column label="直播时间" align="center" prop="clientName" show-overflow-tooltip>
            <template slot-scope="scope">
              <div>{{scope.row.startTime}}-{{scope.row.endTime}}</div>
           </template>
          </el-table-column>
          <el-table-column label="直播地点" align="center" prop="roomName" show-overflow-tooltip></el-table-column>
          <el-table-column label="实际开播时间" align="center" prop="beginLiveTime" width="120" show-overflow-tooltip></el-table-column>
          <el-table-column label="实际直播时长" align="center" prop="liveTime" width="150" show-overflow-tooltip></el-table-column>
          <el-table-column label="关联工单" align="center" prop="workId" show-overflow-tooltip></el-table-column>
          <el-table-column label="直播客户" align="center" prop="clientName" show-overflow-tooltip></el-table-column>
          <el-table-column label="客户负责人" align="center" prop="responsibleName" show-overflow-tooltip></el-table-column>
          <el-table-column label="客户类型" align="center" prop="customerType" show-overflow-tooltip></el-table-column>
          <el-table-column label="投流费（元）" align="center" prop="investmentFee" min-width="100" show-overflow-tooltip></el-table-column>
          <el-table-column label="直播状态" align="center" prop="createTime" show-overflow-tooltip>
            <template slot-scope="scope">
             <dict-tag :options="liveStatusLs" :value="scope.row.liveStatus" />
           </template>
          </el-table-column>
          <el-table-column label="备注" align="center" prop="remarks" show-overflow-tooltip></el-table-column>
        </el-table>
        <pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNum"
          :limit.sync="queryParams.pageSize" @pagination="getList"></pagination>
        </div>

      </div>
      <div class="button_box">
        <el-button type="primary" @click="handleClose">关闭</el-button>
      </div>
    </div>
  </el-drawer>
</template>
<script>
// api
import {
  workforceLiveDetailList
} from "@/api/customer/scheduleList";
import Loading from "@/components/Loading/index";

export default {
  props: {
    visible: Boolean,
    userInfo: Object,
  },
  components: {
    Loading
  },
  data() {
    return {
      inputWidth: "400px",
      title: "查看明细",
      // 遮罩层
      loading: false,
      // 总条数
      total: 0,
      //表格数据
      tabList: [],
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        liveStatus: '',//直播状态
        customerName: '',//直播客户
      },
      liveStatusLs: [], //直播状态
    };
  },
  computed: {},
  created() {
    this.getDict()
    this.getList()
  },
  mounted() {

  },
  computed: {},
  methods: {
    //获取状态字典
    getDict() {
      var dictType = "live_schedule_status";
      this.$getSelectList(dictType)
        .then((res) => {
          this.liveStatusLs = res.result[0].dictList;
        })
    },
    // 以日历形式查看
    calendarViewHandle(){
      // this.handleClose()
      this.$router.push({ path: "/customer/workforceManagement/scheduleList/calendarList", query: { id: this.userInfo.userId,type: 1,date:this.userInfo.date } });
    },
    /** 查询列表 */
    getList() {
      this.loading = true;
      let params = {
          userId:this.userInfo.userId,
          date:this.userInfo.date,
          ...this.queryParams
      }
      workforceLiveDetailList(params).then(response => {
        response.result.records.forEach(item => {
          for (var key in item) {
            if (item[key] === '') {
              item[key] = "-";
            }
          }
        });
        this.tabList = response.result.records;
        this.total = response.result.total;
        this.loading = false;
      });
    },
    // 表单重置
    reset() {
      this.date = []
      this.queryParams = {
        pageNum: 1,
        pageSize: 10,
        liveStatus: '',//直播状态
        customerName: '',//直播客户
      },
        //   this.resetForm("queryParams");
        this.handleQuery()
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      // this.resetForm("queryForm");
      this.reset();
    },
    handleClose(formName) {
      this.$emit("update:visible", false);
    },
  }
};
</script>
<style lang="scss" scoped>
.ex-drawer {
  ::v-deep {
    .el-drawer__header {
       margin-bottom: 0;
       padding-bottom: 10px;
       box-sizing: border-box；
    }
    /*1.显示滚动条：当内容超出容器的时候，可以拖动：*/
    .el-drawer__body {
      overflow: auto;
    }
    /*2.隐藏滚动条，太丑了*/
    .el-drawer__container ::-webkit-scrollbar{
        display: none;
    }
    .main{
      margin-bottom:unset;
      box-shadow: unset;
      padding: 0;
      .head,.listBox_table{
        padding: 0 20px;
      }
      .listBox{
        // padding: 0 20px 20px 20px;
        .listBox_head{
          padding: 0 20px;
          margin-bottom: 20px;
          .listBox_head_top{
            span{
              padding-right: 80px;
            }
          }
        }
        .listBox_line{
          width: 100%;
          border-bottom: 2px solid #cccccc;
          margin-bottom: 20px;
        }
        
      }

    }
  }
}
.button_box {
  display: flex;
  justify-content: center;
  padding: 20px 0;
}
</style>
